#include "viewwidget.h"

ViewWidget::ViewWidget(QObject *parent)
: selecting (false)
{
}

void ViewWidget::wheelEvent(QWheelEvent *event)
{
	int numDegrees = event->delta() / 8;
	int numSteps = numDegrees / 15;

	emit zoomChanged(numSteps);
}

void ViewWidget::mouseDoubleClickEvent (QMouseEvent *event)
{
	if (event->button() == Qt::RightButton)
	{
		emit createPoint (event->posF());
	}
	else
	{
		selecting = true;
		emit mouseDoubleClickDrag (event->posF());
	}
}

void ViewWidget::mouseMoveEvent (QMouseEvent *event)
{
	if (selecting)
		emit mouseMoveDrag (event->posF());
	else
		QGraphicsView::mouseMoveEvent (event);
}

void ViewWidget::mouseReleaseEvent (QMouseEvent *event)
{
	if (selecting)
	{
		selecting = false;
		emit mouseReleaseDrag();
	}
	QGraphicsView::mouseReleaseEvent (event);
}
